package enumdemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test {
    //枚举是不能进行反射的
    public static void main(String[] args) {
        try {
         Class<?> c1 = Class.forName("enumdemo.TestEnum");
            Constructor<?> constructor =
                    c1.getDeclaredConstructor(String.class,int.class,String.class,int.class);
            constructor.setAccessible(true);

            TestEnum testEnum = (TestEnum) constructor.newInstance("WHITE",4);

            System.out.println(testEnum);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
}
